$(function () {
 const id = location.search.substring(4)
 const url1 = `http://124.223.14.236:3001/api/recipe/${id}`
 const url2 = 'http://124.223.14.236:3001/api/recipeInfo/'
// 获取菜单
axios({
  method:'GET',
  url:url1
}).then(function(res){
  console.log(res);
  const menuDetail = res.data.data;
  console.log(menuDetail);
  const img = `http://124.223.14.236:3001/public/${menuDetail.img}`
  document.querySelector('.container .left img').src = img;
  document.querySelector('.container .right h3').innerHTML = menuDetail.name;
  document.querySelector('.container .right p').innerHTML = menuDetail.description;
});
axios({
  method:'GET',
  url:url2,
  params:{
    id
  }
}).then(function(res){
  const list = res.data.data
  if(list.length){
   let strlist = list.map(({ img, title, id},index)=>{
      return `
      <li>
          <a href="../recipeBaseCode/detail.html?id=${id}">
            <img src='http://124.223.14.236:3001/api/public/${img}' alt="" />
            <h3>${title}</h3>
          </a>
        </li>
      `
    }).join('')
    $('#list-box').html(strlist)
  }else{
    document.body.innerHTML += '<p class="noinfo">没有美食哦...</p>';
  }
 
})
});
